package main

import (
	"fmt"
	"math"
)

/**
 * @author: guangcheng
 * @date:   2020/11/12 23:29
 * @version  V1.0
 * @description:
 *
 */
func main() {

	const arrLength = 100
	var needCheckLen int
	needCheckLen = int(math.Sqrt(float64(arrLength)))

	//num1 := new(int)
	////*int  0xc00000a0a0  0xc000006028 0
	//fmt.Printf("%T  %v  %v %v", num1, num1, &num1, *num1)
	//fmt.Println()

	var nonPrime [arrLength]int
	//打印非素数
	for i := 1; i < arrLength; i++ {
		for j := 1; j < needCheckLen; j++ {

			if j == i || j == 1 {
				continue
			} else {
				if i%j == 0 {
					nonPrime[i] = i
				}
			}
		}

	}

	var primeArr [arrLength]int
	for i := range nonPrime {
		//fmt.Printf(" %v", nonPrime[i])
		if i > 4 {
			if nonPrime[i] == 0 {
				primeArr[i] = nonPrime[i-1] + 1
			}
		} else if i == 2 || i == 3 {
			primeArr[i] = i
		}
	}

	newPrimeArrLength := 0
	fmt.Println()
	for i := range primeArr {
		if primeArr[i] != 0 {
			newPrimeArrLength++
			fmt.Printf(" %v", primeArr[i])
			if newPrimeArrLength%20 == 0 {
				fmt.Println()
			}
		}
	}

	fmt.Println("\n素数个数(", arrLength, "以内)", newPrimeArrLength, "个")

}
